<!DOCTYPE html>
<html lang="en">
	<head>
		<title>three.js webgl - collada</title>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
		<style>
			body {
				background:#777;
				padding:0;
				margin:0;
				overflow:hidden;
			}

			#info {
				position: absolute;
				top: 0px;
				width: 100%;
				color: #ffffff;
				padding: 5px;
				font-family:Monospace;
				font-size:13px;
				text-align:center;
			}

			a {
				color: #ffffff;
			}
		</style>
	</head>
	<body>
		<div id="container"></div>
		<script src="three.js"></script>
		<script src="js/ColladaLoader.js"></script>
		<script>


			var container, stats, clock;
			var camera, scene, renderer, elf;

			init();
			animate();

			function init() {
				container = document.getElementById( 'container' );
				camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 0.1, 2000 );
				camera.position.set( 8, 10, 8 );
				camera.lookAt( new THREE.Vector3( 0, 3, 0 ) );
				scene = new THREE.Scene();

				var loadingManager = new THREE.LoadingManager( function() {
					
					elf.position.y =  3;
					//elf.position.set(0,1,0);
					scene.add( elf );
					
				} );
				var loader = new THREE.ColladaLoader( loadingManager );
				loader.load( 'elf/avatar.dae', function ( collada ) {
// 				loader.load( 'elf/elf.dae', function ( collada ) {
					elf = collada.scene;
				} );

				var ambientLight = new THREE.AmbientLight( 0xcccccc, 0.4 );
				scene.add( ambientLight );

				var directionalLight = new THREE.DirectionalLight( 0xffffff, 0.8 );
				directionalLight.position.set( 1, 1, 0 ).normalize();
				scene.add( directionalLight );

				renderer = new THREE.WebGLRenderer();
				renderer.setPixelRatio( window.devicePixelRatio );
				renderer.setSize( window.innerWidth, window.innerHeight );
				container.appendChild( renderer.domElement );
				window.addEventListener( 'resize', onWindowResize, false );
			}

			function onWindowResize() {
				camera.aspect = window.innerWidth / window.innerHeight;
				camera.updateProjectionMatrix();
				renderer.setSize( window.innerWidth, window.innerHeight );
			}

			function animate() {
				requestAnimationFrame( animate );
				render();
			}

			function render() {
				renderer.render( scene, camera );
			}

		</script>
	</body>
</html>
